package com.woniuxy.carrental.service.impl;

import com.woniuxy.carrental.entity.Emp;
import com.woniuxy.carrental.mapper.EmpMapper;
import com.woniuxy.carrental.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author author
 * @create 2021-09-29 19:22
 */
@Service
public class EmpServiceImpl implements EmpService {

    @Autowired
//  @Resource
    EmpMapper empMapper;



//    @Override
//    public Emp checkEmp(String empAcc, String empPwd) {
//        Emp emp = empMapper.findByEmpAccAndEmpPwd(empAcc, MD5Utils.getMD5(empPwd));
//        System.out.println(emp);//null
//        return emp;
//    }

    @Override
    public List<Emp> findAllEmpsByPage(Emp emp, String empname,String status,int pageIndex, int pageSize) {
        List<Emp> emps = empMapper.findAllEmpsByPage(emp, empname,status,pageIndex, pageSize);
        return emps;
    }

    @Override
    public int findEmpsCountByPage(Emp emp) {
        int nums = empMapper.findEmpsCountByPage(emp);
        return nums;
    }

    @Override
    public void addEmp(Emp emp) {
        empMapper.addEmp(emp);
    }

    @Override
    public void deleteEmp(String account) {
        empMapper.deleteEmp(account);
    }

    @Override
    public void updateEmp(Emp emp) {
        empMapper.updateEmp(emp);
    }

    @Override
    public Emp findByAcc(String account) {
        Emp emp = empMapper.findByAcc(account);
        return emp;
    }

    @Override
    public String findPwdByAcc(String account) {
        String password = empMapper.findPwdByAcc(account);
        return password;
    }
}
